<?php
require '../model/Db.php';
$Db = Db::getInstance();
$user_data = $Db->islogin();
if($user_data && $_POST['id']){
	$_POST = $Db->escape($_POST);
	$_POST['str'] = explode(',', $_POST['str']);
	$reason = '';
	foreach ($_POST['str'] as $value) {
		if($value == 0){
			$reason .= '低俗色情,';
		}elseif($value == 1){
			$reason .= '垃圾广告,';
		}elseif($value == 2){
			$reason .= '辱骂攻击,';
		}elseif($value == 3){
			$reason .= '其他违法信息,';
		}
	}
	$reason .= $_POST['reason'];
	$Db->save([
		table => 'report',
		map => [
			cid => $_POST['id'],
			uid => $user_data['id'],
			reason => $reason
		]
	]);
}else{
	http_response_code(404);
	echo '<h1 style="color:#337ab7">千呼万唤始出来,犹抱琵琶半遮面</h1>';
}